#pragma once
#include "CentralCanvasBase.h"
#include "cv.h"
#include "highgui.h"
#include "include\\videoInput.h"
#include "ResourceLocker.h"
class CCamCaptureCavas:
	public OCEANUI::CCentralCanvasBase
{
	Q_OBJECT
public:
	friend void __cdecl captureThreadCallBack(void* pData);

	CCamCaptureCavas(OCEANUI::CMainWindowBase* parent);

	 virtual ~CCamCaptureCavas() { close(); }

	virtual bool open( int index );

	virtual void close();

	virtual double getProperty(int);

	virtual bool setProperty(int, double);

	virtual bool grabFrame();

	virtual IplImage* retrieveFrame();

	void initData(void* pData);
	
signals:
	void SigUpdate();

protected:
	void syncVideoImage(IplImage* pImg);

	void paintEvent(QPaintEvent *event);

private:
	int index_;
	IplImage* frame;
	static videoInput VI;

private:
	IplImage* pCurrentImg_;
	int fps_;
	CRITICAL_SECTION imagelock_;
};
